#include "asynevent.h"


bool AsynEventFramework::Init()
{
#ifdef WIN32
	WSADATA wsa_data;
	if (WSAStartup(MAKEWORD(2,2), &wsa_data) ){
		return false;
	}
#endif

	//evthread_use_windows_threads();

	m_base = event_base_new();
	if (!m_base) {
		fprintf(stderr, "Could not initialize libevent!\n");
		return false;
	}

	return true;
}

bool AsynEventFramework::Uninit()
{

	event_base_free(m_base);

#ifdef WIN32
	WSACleanup();
#endif

	return true;
}

bool AsynEventFramework::Start()
{
	event_base_dispatch(m_base);
	return true;
}

bool AsynEventFramework::Stop()
{
	event_base_loopexit(m_base, NULL);
	return true;
}